package uk.ac.cam.echo.app;

import android.content.Intent;
import android.view.KeyEvent;

public class SecondaryActivity extends ExtendedActivity
{
	protected final Class mainActivity = EchoActivity.class;

	public void goHome()
	{
		Intent i = new Intent(self, mainActivity);
		self.startActivity(i);
		super.finish();
	}

	public void terminate(String errorMessage)
	{
		Intent i = new Intent(self, mainActivity);
		i.putExtra("Exception", errorMessage);
		self.startActivity(i);
		super.finish();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		// replaces the default 'Back' button action
		if (keyCode == KeyEvent.KEYCODE_BACK)
		{
			goHome();
		}
		return true;
	}
}
